//Accepted
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

typedef struct ssss{
	int x;
	int y;
} pppp;

vector<int> v[20];
char isRaiz[20];
char isFolha[20];
pppp p[20];

int d[20];

int n, i, j, x, y, maior;

int altura(int a){
	if(isFolha[a])return 1;
	if(d[a])return d[a];
	
	int xx=0, yy, nn=v[a].size();
	
	for(int jj=0;jj<nn;++jj){
		yy = altura(v[a][jj]);
		if(yy>xx){
			xx=yy;
		}
	}
	
	d[a]=xx+1;
	return d[a];

}
int main (){
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	memset(isRaiz,1,sizeof(isRaiz));
	memset(isFolha,1,sizeof(isFolha));
	memset(d,0,sizeof(d));
	
	scanf("%d", &n);
	
	for(i=0;i<n;++i){
		scanf("%d%d", &p[i].x, &p[i].y);
	}
	
	
	for(i=0;i<n;++i){
		for(j=0;j<n;++j){
			if((p[j].x<p[i].x)&&(p[j].y<p[i].y)){
				isRaiz[j]=0;
				isFolha[i]=0;
				v[i].push_back(j);
			}
		}
	}
	maior=0;
	
	for(i=0;i<n;++i){
		if(isRaiz[i]){
			x=altura(i);
			if(x>maior){
				maior=x;
			}
		}
	}
	printf("%d\n", maior);
	
	return 0;
}
